<?php
namespace addon\cms\logic;
use app\common\logic\LogicBase;
use tpfcore\Core;
use \tpfcore\util\Config;
class MiniChat extends LogicBase
{

    public function saveMiniChat($data=[]){
    	$validate=Core::addonValidate($this->name);
        $validate_result = $validate->scene("add")->check($data);
        if (!$validate_result) {
            return [1, $validate->getError(), null];
        }
        
        foreach ($data as $key => $value) {
            $update_config['mimi_program']['config'][$key]=$value;
        }

        unset($data);

        Config::mult_array_merge(APP_PATH."extra/config.php",$update_config);

        return [0,"操作成功",null];
    }
    public function getMiniChat(){
        return config("config.mimi_program")['config'];
    }   
    public function delMiniChat($data){
        $result=self::deleteObject($data,true);
        if($result){
            return [RESULT_SUCCESS,"操作成功",null];
        }else{
            return [RESULT_ERROR,"操作失败",null];
        }
    }
}